package com.ruoyi.tiktok.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.tiktok.domain.TFolder;
import com.ruoyi.tiktok.mapper.FolderMapper;
import com.ruoyi.tiktok.service.FolderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class TFolderService extends ServiceImpl<FolderMapper, TFolder> implements FolderService {

    @Autowired
    FolderMapper tfolderMapper;

    public AjaxResult addFold(TFolder tFolder){
        String folderName = tFolder.getFolderName();

        if(folderName.equals("test")){
            return AjaxResult.error("文件已经存在");
        }else {
            tFolder.setCreateTime(new Date());
            tFolder.setType(0);
            int plus = tfolderMapper.insertFolder(tFolder);
            return  plus ==1 ?AjaxResult.success("创建成功"): AjaxResult.error("error");
        }
    }


    public List<TFolder> selectFolderList(Long parentId){
        TFolder tFolder = new TFolder();
        tFolder.setParentId(parentId);
        return tfolderMapper.queryList(tFolder);
    }


    public boolean deleteById(Long folderId){
        return tfolderMapper.deleteById(folderId)==1;
    }


    @Override
    public TFolder queryById(Long id, int type) {
        return null;
    }

    @Override
    public List<TFolder> list(TFolder folderPo) {
        return null;
    }

    @Override
    public List<String> getStorageFileNameList(Long id) {
        return null;
    }
}
